//
//  PathView.m
//  DrawRect
//
//  Created by cocoazxj@163.com on 15/4/19.
//  Copyright (c) 2015年 handcool. All rights reserved.
//

#import "PathView.h"

@implementation PathView

- (void)drawRect:(CGRect)rect {
    // Drawing code
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    // 有create copy retain 必须用release
    CGMutablePathRef path1 = CGPathCreateMutable();
    CGPathMoveToPoint(path1, NULL, 10, 10);
    CGPathAddLineToPoint(path1, NULL, 10, 90);
    [[UIColor redColor] set];
    CGContextAddPath(context, path1);
    
    CGMutablePathRef path2 = CGPathCreateMutable();
    CGContextAddEllipseInRect(context, CGRectMake(20, 20, 50, 50));
    [[UIColor blueColor] set];
    CGContextAddPath(context, path2);
    CGContextStrokePath(context);
    
    CGPathRelease(path1);
    CFRelease(path2);
}
@end
